package com.cryptoneedle.garden.service.spring;

import com.cryptoneedle.garden.service.util.ConfigUtil;
import org.apache.dolphinscheduler.client.DolphinSchedulerClient;
import org.apache.dolphinscheduler.client.config.DolphinSchedulerClientConfig;
import org.apache.dolphinscheduler.client.core.auth.AuthType;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;

/**
 * <p>description:  </p>
 *
 * @author CryptoNeedle
 * @date 2025-11-06
 */
@Configuration
public class DolphinSchedulerConfig {


    @Bean
    public DolphinSchedulerClientConfig dolphinSchedulerClientConfig(ConfigUtil configUtil) {
        return DolphinSchedulerClientConfig.builder()
                .baseUrl(configUtil.dsUrl())
                .token("8262551cac87ec7f6898ee62bdfa2841")
                .authType(AuthType.TOKEN)
                .build();
    }

    @Bean
    public DolphinSchedulerClient dolphinSchedulerClient(DolphinSchedulerClientConfig dolphinSchedulerClientConfig) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
        return new DolphinSchedulerClient(dolphinSchedulerClientConfig);
    }
}